package linearList;

public class LinkedStack {
	private StackNode head;
	private StackNode top;
	
	public LinkedStack() {
		this.head=new StackNode(0);
		this.head.next=null;
		top=head;		
	}
	
	public boolean isEmpty() {
		if(head==top) return true;
		return false;
	}
	
	public void push(int x) {
		StackNode node=new StackNode(x);
		node.next=top;
		head.next=node;
		top=head.next;
	} 
	
	public int pop() {
		int ret=0;
		if(top!=head) {
			ret=top.data;
			head.next=top.next;
			top=head.next;
			}
		return ret;
	}
	
	public int getTop() {
		return top.data;
	}
}
